package com.cc.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cc.pojo.domain.Role;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface RoleMapper extends BaseMapper<Role> {
    /**
     * 根据角色id查询权限
     * @param roleId
     * @return
     */
    @Select("select menu_id from cc_role_menu where role_id=#{roleId}")
    List<String> getPermissionsRoleId(Long roleId);

    /**
     * 根据角色id删除权限
     * @param roleId
     */
    @Delete("delete from cc_role_menu where role_id=#{roleId}")
    void deletePermissions(Long roleId);

    void insertPermissions(Long roleId, List<Long> permIds);

    /**
     * 根据角色id查询所有权限key
     * @param roleId
     * @return
     */
    List<String> getPermissionsKeyRoleId(Long roleId);

    /**
     * 根据角色RoleKey查询所有权限key
     * @param roleKey
     * @return
     */
    List<String> getPermissionsKeyByRoleKey(String roleKey);
}